Healthcare Coverage in US

Health Insurance Coverage in US

Code
import pandas as pd
import plotly.express as px
import plotly.io as pio
pio.renderers.default = 'notebook'
data = pd.read_csv("../data/clean_500.csv")

fig = px.scatter_geo(data,
                     lat='Latitude',
                     lon='Longitude',
                     size='Data_Value',
                     hover_name='CityName',
                     hover_data={
                         'StateAbbr': True,
                         'Data_Value': ':.2f',
                         'PopulationCount': True,
                         'Measure': True
                     },
                     color='Data_Value',
                     color_continuous_scale=px.colors.sequential.Teal,
                     projection='albers usa',
                     title='Health Insurance Coverage Map')

#change text pos, color, and size of the bubbles
fig.update_traces(
    textposition='top center',
    marker=dict(
        line=dict(width=0)
    )
);


fig.update_geos(
    landcolor='lightgray',
    bgcolor='white',
    projection_scale=0.95,
    center=dict(lat=37.0902, lon=-95.7129),
    showcountries=True,
    countrycolor='black',
    showsubunits=True,
    subunitcolor='black'
);

#color scale changes
fig.update_layout(
    coloraxis_colorbar=dict(
        title='Data Value (%)',
        thicknessmode='pixels', thickness=15,
        lenmode='pixels', len=200
    ),
    margin=dict(t=50, l=0, r=0, b=0),
    title=dict(
        y=0.95,
        x=0.5,
        xanchor='center',
        yanchor='top'
    )
);

#hover info
fig.update_layout(
    hoverlabel=dict(
        bgcolor="white",
        font_size=16,
        font_family="Rockwell"
    )
);

fig.show()
Figure 1: Health Insurance Coverage Map in US
Code
import plotly.graph_objs as go

measure_col_name = "Data_Value"

state_avg = data.groupby("StateAbbr")[measure_col_name].mean().reset_index()

overall_avg = state_avg[measure_col_name].mean()

max_state = state_avg.loc[state_avg['Data_Value'].idxmax()]

#show the details
state_avg.head(), overall_avg, max_state

#fig for us
fig = go.Figure()

fig.add_trace(go.Bar(
    x=state_avg["StateAbbr"],
    y=state_avg["Data_Value"],
    name="%",
    marker_color="skyblue"
))

fig.add_trace(go.Scatter(
    x=state_avg["StateAbbr"],
    y=[overall_avg] * len(state_avg),
    name="Average",
    line=dict(color="gray", width=2, dash="dash")
))

fig.add_annotation(
    x=max_state['StateAbbr'],
    y=max_state['Data_Value'],
    text=f"State: {max_state['StateAbbr']}<br>Average: {max_state['Data_Value']:.2f} %",
    showarrow=True,
    arrowhead=1
)

fig.update_layout(
    title={
        'text': 'Avg. Health Insurance Coverage by States',
        'y':0.9,
        'x':0.5,
        'xanchor': 'center',
        'yanchor': 'top'},
    xaxis_title="State",
    yaxis_title="Avg. Health Insutance Cover (%)",
    showlegend=False
)

fig.show()
Figure 2: Average Health Insurance Coverage By Satates in US

Interactive plot for the average percentage of health insurance coverage across various US states shows that Texas stands out with the highest coverage rate—almost 28%, well above the national average. The dashed horizontal line across the chart suggests the overall average health insurance coverage, allowing for a quick visual comparison between each state’s coverage and the overall average. This kind of info can really help us see where things are going well and where there’s room for improvement in making sure everyone has access to health care.

Marketplace Premium Data in US

Code
import pandas as pd
import numpy as np
import plotly.graph_objects as go

#import data
enrollment_df = pd.read_csv('../data/kff_enrollment.csv')
metal_tier_df = pd.read_csv('../data/cleaned_kff.csv')
issuers_df = pd.read_csv('../data/issuers.csv')

#retain only the following cols
issuers_df = issuers_df[['Location', 'Number of Issuers in 2024']]

#merge dfs
merged_df = pd.merge(enrollment_df, metal_tier_df, on='Location')
merged_df = pd.merge(merged_df, issuers_df, on='Location')
merged_df = merged_df.drop('Average Benchmark Premium', axis=1)
merged_df = merged_df.drop(index=0)

#calculate avg premium and rank based on premium avg (1 is lowest and 50 is highest)
merged_df['Average Premium'] = merged_df[['Average Lowest-Cost Bronze Premium', 'Average Lowest-Cost Silver Premium', 'Average Lowest-Cost Gold Premium']].mean(axis=1)
merged_df['Average Premium'] = merged_df['Average Premium'].round(2)
merged_df['Overall Rank'] = merged_df['Average Premium'].rank(method='min', ascending=True)

#choose color scale
header_color = 'teal'
col_even_color = 'lightgreen'
col_odd_color = 'white'

#create table
table_fig = go.Figure(data=[go.Table(
    header=dict(
        values=list(merged_df.columns),
        line_color='black',
        fill_color=header_color,
        align='center',
        font=dict(color='white', size=12)
    ),
    cells=dict(
        values=[merged_df[col] for col in merged_df.columns], 
        line_color='black',
        fill_color=[col_odd_color if i % 2 == 0 else col_even_color for i in range(len(merged_df))],
        align='center',
        font=dict(color='black', size=11)
    ))
])

table_fig.update_layout(
    title='Marketplace Premium Data by State, 2024',
    margin={'t': 50}  
)

table_fig.show()
Figure 3: Marketplace Premium Data by US State in 2024

This table summarizes marketplace insurance enrollment by rank and tier in 2024 across all 50 states. Marketplace insurance is defined as health insurance coverage available through the Health Insurance Marketplace through The Affordable Care Act. It is intended to assist families and individuals in attaining affordable healthcare. The table also contains data on the number of marketplace insurance issuers per state, as well as the calculated average premium for each state. Then, we ranked the states in ascending order, meaning the state with the lowest average premium is rank #1 and the state with the highest average premium is rank #50. The marketplace data indicates that West Virginia has the highest premium and Maryland has the lowest average.